package com.oss.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 配置静态资源放行
 * @author chengqiang
 **/
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Value("${outResource}")
    String outResource;

    /**
     * 文档图片等信息映射, 配置映射后 需要在拦截器里面配置不拦截
     * @param registry 资源处理器
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // (配置图片静态资源时,不需要带全局上下文路径)
        registry.addResourceHandler("/doc/**").addResourceLocations("file:"+outResource);
    }
}
